import { Token } from '@/types/data'
import { LoginAction } from '@/types/store'

// token
const initialState: Token = {
  token: '',
  refresh_token: ''
}

// 保存用户登录成功后的token
export const login = (state = initialState, action: LoginAction): Token => {
  // 用户登录成功后，更新redux中的token
  if (action.type === 'login/token') {
    return action.payload
  }
  return state
}
